package com.zte.warehouse.control;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;

@Controller
public class WarehouseHTMLAction {
    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("/currentUsers")
    @ResponseBody
    public String currentUsers(){
        String currentUsersName ="测试人名";
//                (String) redisTemplate.opsForValue().get("currentUsersName");
//        System.out.println(currentUsersName);
        return currentUsersName;
    }

    //仓库管理
    @RequestMapping("/storage/lists")
    public String storageList(){
        return "storage/storage/storageList";
    }
    @RequestMapping("/storage/storage/storageAddPage")
    public String addstorage(){
        return "storage/storage/storageAdd";
    }
    @RequestMapping("/storage/storage/storageUpdate")
    public String updatestorage(int id, HttpSession session){
        session.setAttribute("storageViewid",id);//多
        session.setAttribute("storageUpdateid",id);//多
//        redisTemplate.opsForValue().set("storageViewid",id);
//        redisTemplate.opsForValue().set("storageUpdateid",id);//session??
//        Object storageUpdateid = redisTemplate.opsForValue().get("storageUpdateid");
        System.out.println("设置了storageUpdateid"+id);
        return "storage/storage/storageUpdate";
    }
    @RequestMapping("/storage/storage/storageView")
    public String Viewstorage(int id, HttpSession session){
        session.setAttribute("storageViewid",id);//多
        System.out.println("设置了storageViewid"+id);
        return "storage/storage/storageView";
    }

    //仓库浏览
    @RequestMapping("/storageBrowseCon/lists")
    public String storageBrowse(){
        return "storage/storageBrowse/storageBrowse";
    }

    //出库管理
    @RequestMapping("/ckWarehouse/lists")
    public String deliveryList(){
        return "storage/delivery/deliveryList";
    }
    @RequestMapping("/storage/delivery/deliveryAdd")
    public String Adddelivery(){
        return "storage/delivery/deliveryAdd";
    }
    @RequestMapping("/storage/delivery/deliveryView")
    public String storageView(){
        return "storage/delivery/deliveryView";
    }

    //入库管理
    @RequestMapping("/rkWarehouse/lists")
    public String inventoryList(){
        return "storage/inventory/inventoryList";
    }
    @RequestMapping("/storage/inventory/inventoryAdd")
    public String Addstock(){
        return "storage/inventory/inventoryAdd";
    }
    @RequestMapping("/storage/inventory/inventoryView")
    public String Viewstock(){
        return "storage/inventory/inventoryView";
    }


    //库存管理
    @RequestMapping("/kcWarehouse/lists")
    public String Liststock(){
        return "storage/stock/stockList";
    }

}
